import threading
import time

def task():
    for i in range(20):
        print('执行中')
        time.sleep(1)

if __name__ == '__main__':
    #设置子线程为守护线程deamon
    #方法一
    # sub_thr=threading.Thread(target=task,daemon=True)
    #方法二
    #sub_thr = threading.Thread(target=task)
    # sub_thr.setDaemon(True)
    sub_thr = threading.Thread(target=task)
    sub_thr.start()
    time.sleep(1)
    print('over')